Skip to content

Freshdesk - add support for notes #17598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

seynadio
Copy link

@seynadio seynadio commented Jul 14, 2025

WHY

New Features

  • Added option to specify if a ticket has internal notes and whether the comment is public when updating Freshdesk tickets.

Chores

  • Updated action and package versions for Freshdesk integration.

Summary by CodeRabbit

  • New Features
    • Introduced a new action to add notes or conversations to existing Freshdesk tickets, with options for privacy, incoming status, user ID, and notification emails.
  • Bug Fixes
    • Improved ticket name handling by assigning a default name when unavailable.
    • Enhanced error handling when retrieving ticket names to prevent failures on missing tickets.

Copy link

vercel bot commented Jul 14, 2025

@seynadio is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Walkthrough

The update assigns a default ticket name in the update-ticket action, adds a new action to add notes to Freshdesk tickets with input validation, and introduces a new method addNoteToTicket in the Freshdesk app to post notes via the API with error handling improvements.

Changes

File(s) Change Summary
components/freshdesk/actions/update-ticket/update-ticket.mjs Assigned default "Unknown Ticket" if ticket name retrieval returns falsy.
components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs Added new action to add a note to a Freshdesk ticket with input validation and API interaction.
components/freshdesk/freshdesk.app.mjs Updated getTicketName with 404 error handling; added new async method addNoteToTicket to post notes to tickets.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AddNoteAction
    participant FreshdeskApp
    participant FreshdeskAPI

    User->>AddNoteAction: Invoke add-note-to-ticket with props
    AddNoteAction->>FreshdeskApp: addNoteToTicket(ticketId, data)
    FreshdeskApp->>FreshdeskAPI: POST /tickets/{ticketId}/notes with data
    FreshdeskAPI-->>FreshdeskApp: Note creation response
    FreshdeskApp-->>AddNoteAction: Return response
    AddNoteAction-->>User: Return summary and API response
Loading

Poem

🐇 A note to add, a ticket to cheer,
Freshdesk listens, the message is clear.
From rabbit’s paws, a new action springs,
Adding notes with swift, gentle wings.
Version bumped up, and features anew,
Hopping along with code fresh and true! 🌿✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

components/freshdesk/actions/update-ticket/update-ticket.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)

components/freshdesk/freshdesk.app.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at Object.getPackageJSONURL (node:internal/modules/package_json_reader:255:9)
at packageResolve (node:internal/modules/esm/resolve:767:81)
at moduleResolve (node:internal/modules/esm/resolve:853:18)
at defaultResolve (node:internal/modules/esm/resolve:983:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:801:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:725:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:708:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:309:38)
at #link (node:internal/modules/esm/module_job:202:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7803162 and 65ee116.

📒 Files selected for processing (3)
  • components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (1 hunks)
  • components/freshdesk/actions/update-ticket/update-ticket.mjs (1 hunks)
  • components/freshdesk/freshdesk.app.mjs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/freshdesk/actions/update-ticket/update-ticket.mjs
🧰 Additional context used
🧬 Code Graph Analysis (1)
components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (1)
components/freshdesk/actions/update-ticket/update-ticket.mjs (2)
  • ticketName (103-103)
  • data (101-101)
🔇 Additional comments (7)
components/freshdesk/freshdesk.app.mjs (1)

253-264: Good error handling implementation!

The addition of try-catch error handling properly addresses the concern about missing tickets. Returning null for 404 errors allows callers to handle non-existent tickets gracefully while still propagating other errors.

components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (6)

1-51: Component structure follows Pipedream guidelines well.

The component properly follows the naming convention, uses prop definitions from the app file, and implements optional props with sensible defaults. The prop descriptions are clear and informative.


63-65: Input validation for note body is appropriate.

The validation correctly prevents empty or whitespace-only note bodies and uses the appropriate ConfigurationError for user input validation.


67-67: Ticket name retrieval with fallback is well-implemented.

The code correctly uses the updated getTicketName method with a fallback to "Unknown Ticket", which is consistent with the pattern used in the update-ticket action.


78-84: User ID validation is thorough and appropriate.

The validation correctly handles the optional user_id parameter, ensures it's a valid number, and only includes it in the data object when valid.


86-93: Email validation is well-implemented with informative error messages.

The validation correctly checks all email addresses and provides a comprehensive error message listing all invalid emails. The regex pattern is sufficient for basic email validation.


95-102: Method execution and response handling is correct.

The code properly calls the addNoteToTicket method with validated parameters, exports an informative summary, and returns the API response. The number conversion for ticketId ensures type consistency.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

vercel bot commented Jul 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jul 18, 2025 0:33am

@adolfo-pd adolfo-pd added the User submitted Submitted by a user label Jul 14, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/freshdesk/actions/update-ticket/update-ticket.mjs (1)

74-86: Properties look good but consider validation enhancement.

The new properties are well-defined with clear descriptions and appropriate types.

Consider adding validation to ensure noteBody is provided when internalNote is true:

 noteBody: {
   type: "string",
   label: "Note Body",
   description: "The content of the internal note to add.",
   optional: true,
+  reloadProps: true,
 },

Or add a conditional requirement in the property definition.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e21d334 and fc704c0.

📒 Files selected for processing (1)
  • components/freshdesk/actions/update-ticket/update-ticket.mjs (3 hunks)
🔇 Additional comments (3)
components/freshdesk/actions/update-ticket/update-ticket.mjs (3)

8-8: LGTM: Version increment is appropriate.

The version bump from 0.0.1 to 0.0.2 correctly reflects the addition of new functionality.


111-112: LGTM: Destructuring correctly extracts new properties.

The destructuring properly extracts the new properties while maintaining the existing ...fields pattern.


135-149: LGTM: Existing logic preserved correctly.

The existing ticket update logic remains intact and functions as expected when not adding internal notes.

Comment on lines 120 to 133
if (internalNote && noteBody) {
const response = await freshdesk._makeRequest({
$,
method: "POST",
url: `/tickets/${ticketId}/notes`,
data: {
body: noteBody,
private: true,
},
});

$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`);
return response;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Address the either/or behavior limitation and validation gap.

The current implementation has two design issues:

  1. Either/or limitation: Users can either add an internal note OR update ticket fields, but not both in the same action call. This may not meet user expectations.

  2. Validation gap: If internalNote is true but noteBody is empty/falsy, the function proceeds to regular update logic, potentially throwing a confusing "Please provide at least one field to update" error.

Consider these improvements:

Option 1: Allow both operations in sequence

 if (internalNote && noteBody) {
-  const response = await freshdesk._makeRequest({
+  await freshdesk._makeRequest({
     $,
     method: "POST",
     url: `/tickets/${ticketId}/notes`,
     data: {
       body: noteBody,
       private: true,
     },
   });
-  
-  $.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`);
-  return response;
+ }
+ 
+ if (internalNote && !noteBody) {
+   throw new Error("Note Body is required when Internal note is enabled.");
 }

Option 2: Add validation for the either/or scenario

+ if (internalNote && !noteBody) {
+   throw new Error("Note Body is required when Internal note is enabled.");
+ }
+ 
 if (internalNote && noteBody) {
   // existing logic
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (internalNote && noteBody) {
const response = await freshdesk._makeRequest({
$,
method: "POST",
url: `/tickets/${ticketId}/notes`,
data: {
body: noteBody,
private: true,
},
});
$.export("$summary", `Internal note added to ticket "${ticketName}" (ID: ${ticketId})`);
return response;
}
if (internalNote && noteBody) {
await freshdesk._makeRequest({
$,
method: "POST",
url: `/tickets/${ticketId}/notes`,
data: {
body: noteBody,
private: true,
},
});
}
if (internalNote && !noteBody) {
throw new Error("Note Body is required when Internal note is enabled.");
}
🤖 Prompt for AI Agents
In components/freshdesk/actions/update-ticket/update-ticket.mjs around lines 120
to 133, the code currently only allows adding an internal note or updating
ticket fields, not both, and lacks validation when internalNote is true but
noteBody is empty. To fix this, modify the logic to support performing both
actions sequentially if both internalNote and ticket updates are provided, or
alternatively, add validation to check if internalNote is true but noteBody is
missing and return a clear error before proceeding. This ensures users can
update tickets and add notes in one call or receive proper feedback if required
inputs are missing.

Afstkla and others added 3 commits July 18, 2025 14:03
- Created dedicated add-note-to-ticket action for better separation of concerns
- Removed note functionality from update-ticket action to maintain single responsibility
- Added addNoteToTicket method to freshdesk.app.mjs
- Bumped update-ticket version to 0.0.3

This provides a cleaner API where each action has a clear, single purpose.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (2)

78-80: Ensure type safety for user_id parameter.

The explicit conversion to Number is good practice, but consider adding validation to ensure the conversion is successful.

Apply this diff to add validation:

     if (user_id) {
-      data.user_id = Number(user_id);
+      const userId = Number(user_id);
+      if (isNaN(userId)) {
+        throw new ConfigurationError("User ID must be a valid number");
+      }
+      data.user_id = userId;
     }

82-84: Add validation for notify_emails array.

Consider validating that the email addresses are properly formatted to prevent API errors.

Apply this diff to add email validation:

     if (notify_emails && notify_emails.length > 0) {
+      const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
+      const invalidEmails = notify_emails.filter(email => !emailRegex.test(email));
+      if (invalidEmails.length > 0) {
+        throw new ConfigurationError(`Invalid email addresses: ${invalidEmails.join(", ")}`);
+      }
       data.notify_emails = notify_emails;
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc704c0 and 00fe76b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (1 hunks)
  • components/freshdesk/actions/update-ticket/update-ticket.mjs (1 hunks)
  • components/freshdesk/freshdesk.app.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/freshdesk/actions/update-ticket/update-ticket.mjs
🔇 Additional comments (4)
components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs (4)

4-9: LGTM! Action metadata follows conventions.

The action key follows the required naming convention (app_name_slug-slugified-component-name) and includes proper metadata fields.


10-51: Props definition looks comprehensive and well-structured.

The props are well-defined with appropriate types, labels, descriptions, and optional flags. Good use of propDefinitions for reusable props like ticketId and agentId.


63-65: Input validation is appropriate.

The validation ensures the note body is not empty, which prevents unnecessary API calls with invalid data.


86-94: API call implementation and response handling look correct.

The implementation properly passes the context object ($), converts ticketId to Number for type safety, and provides a meaningful summary message.

throw new ConfigurationError("Note body cannot be empty");
}

const ticketName = await freshdesk.getTicketName(ticketId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify error handling for getTicketName method.

Ensure that if the ticket doesn't exist, the error is handled gracefully.

Run the following script to check if getTicketName has proper error handling:


🏁 Script executed:

#!/bin/bash
# Check if getTicketName method has error handling for non-existent tickets
ast-grep --pattern $'async getTicketName($TICKET_ID) {
  $$$
}'

Length of output: 64


To locate the getTicketName implementation and inspect its error handling, let’s search for its definition across the codebase:


🏁 Script executed:

#!/bin/bash
# Find all occurrences of getTicketName to locate its implementation
rg -n "getTicketName" --color=never

Length of output: 989


Let’s inspect the implementation around line 253 to see how errors are handled:


🏁 Script executed:

#!/bin/bash
# Show getTicketName implementation with context
rg -n "async getTicketName" -A15 -B5 components/freshdesk/freshdesk.app.mjs

Length of output: 612


To verify how missing tickets are handled, let’s inspect the getTicket implementation:


🏁 Script executed:

#!/bin/bash
# Show getTicket implementation with context to check error handling
rg -n "async getTicket" -A15 -B5 components/freshdesk/freshdesk.app.mjs

Length of output: 1134


Let’s inspect the _makeRequest implementation to see how it handles HTTP errors (e.g., 404 for non-existent tickets):


🏁 Script executed:

#!/bin/bash
# Locate _makeRequest implementation with surrounding context
rg -n "async _makeRequest" -A20 -B5 components/freshdesk/freshdesk.app.mjs

Length of output: 805


Add explicit error handling for missing tickets in getTicketName

The getTicketName helper currently propagates any errors (including 404s) up to the caller. We need to catch “ticket not found” errors and handle them gracefully—either by returning null (or a default) or by surfacing a clear, user-friendly error.

Affected locations:

  • components/freshdesk/freshdesk.app.mjs at getTicketName (around line 253)
  • components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs at the call site (line 67)

Proposed changes:

  1. Wrap getTicketName implementation in a try/catch and handle HTTP 404:
--- a/components/freshdesk/freshdesk.app.mjs
+++ b/components/freshdesk/freshdesk.app.mjs
@@ -251,7 +251,15 @@
     async getTicketName(ticketId) {
-      const ticket = await this.getTicket({ ticketId });
-      return ticket.subject;
+      try {
+        const ticket = await this.getTicket({ ticketId });
+        return ticket.subject;
+      } catch (error) {
+        if (error.response?.status === 404) {
+          // Ticket not found; return null or a default placeholder
+          return null;
+        }
+        // Re-throw other errors
+        throw error;
+      }
     },
  1. Handle the null (or fallback) at the action layer so the flow doesn’t break unexpectedly:
--- a/components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs
+++ b/components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs
@@ -64,7 +64,13 @@
     const ticketId = await freshdesk.searchTickets({ /* … */ });
-    const ticketName = await freshdesk.getTicketName(ticketId);
+    let ticketName;
+    try {
+      ticketName = await freshdesk.getTicketName(ticketId);
+      if (!ticketName) {
+        // Optional: handle missing ticket (e.g., log warning or set default)
+        ticketName = "Unknown Ticket";
+      }
+    } catch (error) {
+      throw new Error(`Failed to fetch ticket name: ${error.message}`);
+    }

     // … proceed with adding the note

This ensures that 404s don’t crash your action and that any other errors bubble up clearly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const ticketName = await freshdesk.getTicketName(ticketId);
async getTicketName(ticketId) {
try {
const ticket = await this.getTicket({ ticketId });
return ticket.subject;
} catch (error) {
if (error.response?.status === 404) {
// Ticket not found; return null or a default placeholder
return null;
}
// Re-throw other errors
throw error;
}
},
Suggested change
const ticketName = await freshdesk.getTicketName(ticketId);
const ticketId = await freshdesk.searchTickets({ /* … */ });
let ticketName;
try {
ticketName = await freshdesk.getTicketName(ticketId);
if (!ticketName) {
// Optional: handle missing ticket (e.g., log warning or set default)
ticketName = "Unknown Ticket";
}
} catch (error) {
throw new Error(`Failed to fetch ticket name: ${error.message}`);
}
// … proceed with adding the note
🤖 Prompt for AI Agents
In components/freshdesk/actions/add-note-to-ticket/add-note-to-ticket.mjs at
line 67, the call to getTicketName does not handle the case where the ticket is
missing (HTTP 404). Update the getTicketName function in
components/freshdesk/freshdesk.app.mjs around line 253 to wrap its logic in a
try/catch block that catches 404 errors and returns null or a default value
instead of throwing. Then, at the call site in add-note-to-ticket.mjs line 67,
check if the returned ticketName is null or fallback and handle that case
gracefully to prevent the action from breaking unexpectedly.

Afstkla and others added 2 commits July 18, 2025 14:10
- Add JSDoc documentation to addNoteToTicket method
- Add error handling for missing tickets in getTicketName (returns null for 404)
- Add validation for user_id parameter to ensure valid number
- Add email validation for notify_emails array
- Update ticket name handling to use fallback when null

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Afstkla
Copy link
Contributor

Afstkla commented Jul 18, 2025

I've addressed all the code review comments from CodeRabbit:

  1. ✅ Added JSDoc documentation to the addNoteToTicket method in freshdesk.app.mjs
  2. ✅ Added error handling for missing tickets in getTicketName method (returns null for 404 errors)
  3. ✅ Added validation for user_id parameter to ensure it's a valid number
  4. ✅ Added email validation for notify_emails array
  5. ✅ Updated ticket name handling to use fallback "Unknown Ticket" when null

All changes have been tested and committed. The PR is ready for review.

@GTFalcao GTFalcao self-requested a review July 18, 2025 19:06
Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @seynadio , looks good to me, I'll move it forward to be QA'd!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Projects
Development

Successfully merging this pull request may close these issues.

5 participants